
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
	#region StockUpdateResult Model -(by fangyifeng at 2013-06-06 11:57:09)

	/// <summary>
	/// StockUpdateResult object'StockUpdateResult'.
	/// </summary>
	public class StockUpdateResult : System.IComparable
		{
		#region Member Variables
		
		protected Guid _id;
		protected DateTime _upDatedTime;
		
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public StockUpdateResult() { }

		public StockUpdateResult( DateTime upDatedTime )
		{
			this._upDatedTime = upDatedTime;
		}

        public StockUpdateResult(Guid id, DateTime upDatedTime)
        {
            this._upDatedTime = upDatedTime;
            _id = id;
        }

		#endregion

		#region Public Properties

		public virtual Guid Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public virtual DateTime UpDatedTime
		{
			get { return _upDatedTime; }
			set { _upDatedTime = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
			if (!(obj is StockUpdateResult))
				throw new InvalidCastException("This object is not of type StockUpdateResult");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((StockUpdateResult)obj).Id);
					break;
				case "UpDatedTime":
					relativeValue = this.UpDatedTime.CompareTo(((StockUpdateResult)obj).UpDatedTime);
					break;
                default:
                    goto case "Id";
			}
            if (StockUpdateResult.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
